/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', Arial, sans-serif;
    background-color: #f8fafc;
    color: #334155;
    line-height: 1.6;
}

/* 容器布局 */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.1);
}

.header h1 {
    font-size: 2.2rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* 主要内容区域 */
.main-content {
    display: flex;
    flex: 1;
    gap: 15px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

/* 左侧参考案例区域 */
.examples-sidebar {
    width: 320px;
    min-width: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: width 0.3s ease, margin 0.3s ease;
}

.examples-sidebar.collapsed {
    width: 0;
    min-width: 0;
    margin-right: -15px;
    overflow: hidden;
}

.examples-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.examples-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.expand-examples-btn {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.expand-examples-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.toggle-btn.small {
    padding: 4px 8px;
    font-size: 11px;
}

.examples-content {
    padding: 20px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.example-item {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.example-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.example-item h4 {
    color: #333;
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

.example-text {
    font-size: 13px;
    line-height: 1.6;
    color: #555;
}

.example-text p {
    margin: 8px 0;
}

.example-text strong {
    color: #333;
    font-weight: 600;
}

.example-text ul {
    margin: 8px 0;
    padding-left: 20px;
}

.example-text li {
    margin: 4px 0;
}

/* 中间编辑器区域 */
.editor-section {
    flex: 1;
    min-width: 400px;
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
}

.editor-header h2 {
    color: #1e293b;
    font-size: 1.4rem;
    font-weight: 600;
}

.editor-tools {
    display: flex;
    gap: 8px;
}

.tool-btn {
    padding: 6px 12px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: #475569;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

#contentEditor {
    width: 100%;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    min-height: 500px;
    font-family: 'Consolas', 'Monaco', monospace;
    background: #fafafa;
    transition: border-color 0.2s;
}

#contentEditor:focus {
    outline: none;
    border-color: #2563eb;
    background: white;
}

#contentEditor::placeholder {
    color: #94a3b8;
    line-height: 1.8;
}

/* 右侧AI功能区域 */
.ai-section {
    width: 380px;
    min-width: 350px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* API配置区域 */
.api-config {
    border-bottom: 1px solid #eee;
}

.config-header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.config-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.config-panel {
    padding: 15px 20px;
    background: #f8f9fa;
}

.config-item {
    margin-bottom: 12px;
}

.config-item label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.config-item input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 8px;
    box-sizing: border-box;
}

.config-item input:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.2);
}

.save-btn {
    background: #4facfe;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.save-btn:hover {
    background: #3d8bfe;
}

.config-status {
    margin-bottom: 10px;
    font-size: 12px;
}

.config-status span {
    padding: 3px 8px;
    border-radius: 4px;
    background: #ffeaa7;
    color: #d63031;
    font-weight: 500;
}

.config-status span.configured {
    background: #00b894;
    color: white;
}

.config-help {
    font-size: 11px;
    color: #666;
}

.config-help a {
    color: #4facfe;
    text-decoration: none;
}

.config-help a:hover {
    text-decoration: underline;
}

/* AI功能按钮区域 */
.ai-functions {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.ai-functions h2 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.function-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    width: 100%;
}

.ai-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.polish-btn:hover {
    border-color: #f59e0b;
    background: #fffbeb;
}

.expand-btn:hover {
    border-color: #10b981;
    background: #ecfdf5;
}

.summarize-btn:hover {
    border-color: #6366f1;
    background: #eef2ff;
}

.btn-icon {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.btn-text {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 2px;
}

.btn-desc {
    font-size: 0.85rem;
    color: #64748b;
}

.ai-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* AI结果显示区域 */
.ai-result {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
}

.result-header h3 {
    color: #1e293b;
    font-size: 1.2rem;
    font-weight: 600;
}

.copy-btn {
    padding: 6px 12px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: #059669;
}

.result-content {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.placeholder {
    text-align: center;
    color: #94a3b8;
    padding: 40px 20px;
}

.placeholder p {
    margin-bottom: 8px;
}

.ai-response {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.6;
}

/* 样例展示区域 */
.examples-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
}

.examples-section h3 {
    color: #1e293b;
    font-size: 1.2rem;
    margin-bottom: 16px;
    font-weight: 600;
}

.examples-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.example-item {
    border-left: 4px solid #2563eb;
    padding-left: 12px;
}

.example-item h4 {
    color: #1e293b;
    font-size: 1rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.example-item ul {
    list-style: none;
    padding-left: 0;
}

.example-item li {
    color: #64748b;
    font-size: 0.9rem;
    margin-bottom: 4px;
    padding-left: 16px;
    position: relative;
}

.example-item li::before {
    content: "•";
    color: #2563eb;
    position: absolute;
    left: 0;
}

/* 底部样式 */
.footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    color: #64748b;
    font-size: 0.9rem;
}

.footer a {
    color: #2563eb;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* 加载模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .examples-sidebar {
        width: 280px;
        min-width: 250px;
    }
    
    .ai-section {
        width: 350px;
        min-width: 320px;
    }
}

@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
        gap: 20px;
    }
    
    .examples-sidebar {
        width: 100%;
        min-width: auto;
        order: 3;
    }
    
    .editor-section {
        order: 1;
    }
    
    .ai-section {
        width: 100%;
        min-width: auto;
        order: 2;
    }
    
    .function-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .ai-btn {
        flex: 1;
        min-width: 120px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .editor-section,
    .ai-functions,
    .ai-result,
    .examples-section {
        padding: 16px;
    }
    
    #contentEditor {
        min-height: 300px;
    }
    
    .function-buttons {
        flex-direction: column;
    }
    
    .ai-btn {
        min-width: auto;
        padding: 15px;
    }
    
    .btn-text {
        font-size: 14px;
    }
    
    .btn-desc {
        font-size: 11px;
    }
    
    .examples-content {
        max-height: 300px;
    }
}

/* AI对话窗口样式 */
.chat-section {
    width: 380px;
    min-width: 350px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 600px;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-controls {
    display: flex;
    gap: 8px;
}

.export-btn, .clear-btn {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.export-btn:hover, .clear-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
}

.chat-placeholder {
    text-align: center;
    color: #64748b;
    margin-top: 50px;
}

.chat-placeholder p {
    margin: 8px 0;
}

.chat-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.user-message {
    align-items: flex-end;
}

.ai-message {
    align-items: flex-start;
}

.message-content {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
}

.user-message .message-content {
    background: #4facfe;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

.chat-input-area {
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    background: white;
}

.chat-input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#chatInput {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    font-size: 14px;
    resize: none;
    transition: border-color 0.2s;
}

#chatInput:focus {
    outline: none;
    border-color: #4facfe;
}

.send-btn {
    padding: 10px 20px;
    background: #4facfe;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
}

.send-btn:hover {
    background: #3b82f6;
    transform: translateY(-1px);
}

.send-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

/* AI功能区域隐藏/展开样式 */
.collapse-ai-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.collapse-ai-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.expand-ai-btn {
    position: fixed;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: #4facfe;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.4);
    transition: all 0.3s ease;
    z-index: 1001;
}

.expand-ai-btn:hover {
    background: #3b82f6;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.6);
}

.ai-section {
    position: relative;
    transition: all 0.3s ease;
}

.ai-section.collapsed {
    display: none;
}

.chat-section.collapsed {
    display: none;
}